<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
    <script src="https://cdn.bootcss.com/angular.js/1.6.3/angular.min.js"></script>
</head>
<body>

<div ng-app="myApp" ng-controller="customersCtrl" style="margin: 25px">

    <form class="form-inline">
        <div class="form-group">
            <!--<label class="sr-only" for="exampleInputEmail3">姓名</label>-->
            <input type="text" class="form-control" placeholder="姓名" ng-model="searchModel.name">
        </div>
        <div class="form-group">
            <!--<label class="sr-only" for="exampleInputPassword3">Password</label>-->
            <input type="text" class="form-control" placeholder="电话号码" ng-model="searchModel.phone">
        </div>
        <button type="submit" class="btn btn-default" ng-click="search()">搜索</button>
        <button type="submit" class="btn btn-default" ng-click="reset()">重置</button>
    </form>


    <div class="panel panel-default" style="margin-top: 20px;">
        <div class="panel-heading">
            米房 - 通过手机号、姓名查询
        </div>
        <!-- /.panel-heading -->
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>电话号码</th>
                        <th>逾期天数</th>
                        <th>逾期金额</th>
                        <th>逾期时间</th>
                        <th>状态</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="mf in mfData">
                        <td>{{ mf.name }}</td>
                        <td>{{ mf.phone }}</td>
                        <td>{{ mf.days }}</td>
                        <td>{{ mf.money }}</td>
                        <td>{{ mf.overtime }}</td>
                        <td>{{ mf.state == 0 ? '无逾期' : '逾期' }}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <!-- /.table-responsive -->
        </div>
        <!-- /.panel-body -->
    </div>


    <div class="panel panel-default" style="margin-top: 10px">
        <div class="panel-heading">
            今借到 - 通过手机号查询
        </div>
        <!-- /.panel-heading -->
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>电话号码</th>
                        <th>身份证</th>
                        <th>总借</th>
                        <th>总笔</th>
                        <th>当借</th>
                        <th>当前逾期额</th>
                        <th>当前逾期笔</th>
                        <th>历史逾期额</th>
                        <th>历史逾期笔</th>
                        <th>举报</th>
                        <th>信用分</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="jjd in jjdData">
                        <td>{{ jjd.name }}</td>
                        <td>{{ jjd.phone }}</td>
                        <td>{{ jjd.id }}</td>
                        <td>{{ jjd.borrowAmount }}</td>
                        <td>{{ jjd.borrowCount }}</td>
                        <td>{{ jjd.currentBorrowAmount }}</td>
                        <td>{{ jjd.currentOverAmount }}</td>
                        <td>{{ jjd.currentOverCount }}</td>
                        <td>{{ jjd.historyOverAmount }}</td>
                        <td>{{ jjd.historyOverCount }}</td>
                        <td>{{ jjd.reportCount }}</td>
                        <td>{{ jjd.credit }}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <!-- /.table-responsive -->
        </div>
        <!-- /.panel-body -->
    </div>


</div>

<script>
    var app = angular.module('myApp', []);
    app.controller('customersCtrl', function ($scope, $http) {
        $scope.searchModel = {
            phone: '',
            name: ''
        };
        $scope.jjdToken == "";

        $scope.getMFData = function (name, phone) {
            $scope.mfData = [];
            if (name != '' && phone != '') {
                $http.get("https://hhd-api.tmindtech.com/v1/ious/public_overtime/new?name=" + name + "&phone=" + phone)
                    .then(function (result) {
                        $scope.mfData = result.data.data_list;
                        angular.forEach($scope.mfData, function (data) {
                            data.name = name;
                            data.phone = phone;
                        });

                    });
            }


        };


        $scope.getJJDData = function (phone) {
            $scope.jjdData = [];
            $http.get("https://www.gushistory.com/jjdApi/user/login?c_telephone=13110794581&c_pwd=ddcbd72295ea14668e057b7010c12345&timestamp=" + Date.parse(new Date()).toString().substr(0, 10))
                .then(function (result1) {
                    $http.get("https://www.gushistory.com/jjdApi/my/searchFriend?tel=" + phone + "&token=" + result1.data.object.token + "&timestamp=" + Date.parse(new Date()).toString().substr(0, 10))
                        .then(function (result2) {
                            $http.get("https://www.gushistory.com/jjdApi/report/getSimpleReport?userId=" + result2.data.object.id + "&token=" + result1.data.object.token + "&timestamp=" + Date.parse(new Date()).toString().substr(0, 10))
                                .then(function (result3) {
                                    var info = {};
                                    info.name = result3.data.object.c_name;
                                    info.phone = result3.data.object.c_mobil_phone;
                                    info.id = result3.data.object.id_card_num;
                                    info.borrowAmount = result3.data.object.n_borrow_amt;
                                    info.borrowCount = result3.data.object.n_borrow_cnt;
                                    info.currentBorrowAmount = result3.data.object.n_current_borrow_amt;
                                    info.currentOverAmount = result3.data.object.n_current_overdue_amt;
                                    info.historyOverAmount = result3.data.object.n_history_overdue_max;
                                    info.historyOverCount = result3.data.object.n_overdue_cnt;
                                    info.credit = result3.data.object.n_zhima_credit_score;
                                    info.currentOverCount = result3.data.object.n_current_overdue_cnt;
                                    info.reportCount = result3.data.object.n_reported_cnt;
                                    $scope.jjdData.push(info);
                                });
                        });

                });


        };

        $scope.search = function () {
			$http.get("http://127.0.0.1:8080/v0.1/shop", {
            headers : {'Authorization': 'MGEwMjI2NGUtMTM2NS00Yjc2LTg0NjAtNDhjNjRiZjY5M2Qz'}
        }).then(function (result) {
				console.log(result);
			});
		
            // $scope.getMFData('尹国伟', '18534904459');
            // $scope.getJJDData('18534904459');
            // $scope.getMFData('姜云飞', '15040537126');
            // $scope.getJJDData('15040537126');
        };


        $scope.reset = function () {
            $scope.searchModel = {
                phone: '',
                name: '',
                id: ''
            };
        };


    });
</script>
</body>
</html>